<?php
/**
 * 同步部门模型
 * @author sundongdong
 *
 */
class Interface_Model_Department extends Model_Base {
	/**
	 * 查重
	 * @param number $department_id
	 */
	public function existDept($department_id=0) {
		return $this->db()->fetchOne("select department_id from `s_department` where department_id=:id", array('id'=>$department_id));
	}
	/**
	 * 更新部门信息
	 * @param array $data
	 * @param unknown $department_id
	 */
	public function updateDept(array $data, $department_id) {
		try {
			$this->db('write_db')->update('s_department', $data, 'department_id='.$department_id);
		} catch (Exception $e) {
			throw $e;
		}
	}
	/**
	 * 添加部门
	 * @param array $data
	 */
	public function insertDept(array $data) {
		try {
			$this->db('write_db')->insert('s_department', $data);
		} catch (Exception $e) {
			throw $e;
		}
	}
}